package com.esri.android.map;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;

/* loaded from: classes.dex */
public class CalloutStyle {
    static final int a = 0;
    private static final int b = 5;
    private int c;
    private int d;
    private int e;
    private int f;
    private Typeface g;
    private int h;
    private int i;
    private int j;
    private int k;
    private int l;
    private int m;
    private boolean n;

    public CalloutStyle() {
        this.c = 5;
        this.d = -16777216;
        this.e = 10;
        this.f = 0;
        this.g = Typeface.DEFAULT;
        this.h = -1;
        this.i = 255;
        this.j = -16777216;
        this.k = 5;
        this.l = 0;
        this.m = 0;
        this.n = false;
    }

    public CalloutStyle(Context context) {
        this.c = 5;
        this.d = -16777216;
        this.e = 10;
        this.f = 0;
        this.g = Typeface.DEFAULT;
        this.h = -1;
        this.i = 255;
        this.j = -16777216;
        this.k = 5;
        this.l = 0;
        this.m = 0;
        this.n = false;
        this.c = b(this.c, context);
    }

    public CalloutStyle(Context context, AttributeSet attributeSet) {
        this.c = 5;
        this.d = -16777216;
        this.e = 10;
        this.f = 0;
        this.g = Typeface.DEFAULT;
        this.h = -1;
        this.i = 255;
        this.j = -16777216;
        this.k = 5;
        this.l = 0;
        this.m = 0;
        this.n = false;
        this.l = a(context, attributeSet, "maxWidthDp", "maxWidth", 0);
        this.m = a(context, attributeSet, "maxHeightDp", "maxHeight", 0);
        this.h = a(context, attributeSet, "backgroundColor", -1);
        this.i = attributeSet.getAttributeIntValue(null, "backgroundAlpha", 255);
        this.j = a(context, attributeSet, "frameColor", -16777216);
        this.d = a(context, attributeSet, "titleTextColor", -16777216);
        this.e = attributeSet.getAttributeIntValue(null, "titleTextSize", 10);
        this.f = attributeSet.getAttributeIntValue(null, "titleTextStyle", 0);
        this.g = Typeface.create(attributeSet.getAttributeValue(null, "titleTextTypeface"), 0);
        this.c = a(context, attributeSet, "cornerCurveDp", "cornerCurve", 5);
        setAnchor(attributeSet.getAttributeIntValue(null, "anchor", 5));
    }

    private int a(Context context, AttributeSet attributeSet, String str, String str2, int i) {
        int attributeIntValue = attributeSet.getAttributeIntValue(null, str, -1);
        if (attributeIntValue > 0) {
            return b(attributeIntValue, context);
        }
        int attributeIntValue2 = attributeSet.getAttributeIntValue(null, str2, -1);
        return attributeIntValue2 < 0 ? b(i, context) : attributeIntValue2;
    }

    private int a(Context context, AttributeSet attributeSet, String str, int i) {
        int attributeResourceValue = attributeSet.getAttributeResourceValue(null, str, -1);
        if (attributeResourceValue > -1) {
            return context.getResources().getColor(attributeResourceValue);
        }
        return attributeSet.getAttributeIntValue(null, str, i);
    }

    public int getCornerCurve() {
        return this.c;
    }

    public int getCornerCurveDp(Context context) {
        return a(this.c, context);
    }

    public void setCornerCurve(int i) {
        this.c = i;
    }

    public void setCornerCurveDp(int i, Context context) {
        this.c = b(i, context);
    }

    @Deprecated
    public int getTitleTextColor() {
        return this.d;
    }

    @Deprecated
    public void setTitleTextColor(int i) {
        this.d = i;
    }

    @Deprecated
    public int getTitleTextSize() {
        return this.e;
    }

    @Deprecated
    public void setTitleTextSize(int i) {
        this.e = i;
    }

    @Deprecated
    public int getTitleTextStyle() {
        return this.f;
    }

    @Deprecated
    public void setTitleTextStyle(int i) {
        this.f = i;
    }

    @Deprecated
    public Typeface getTitleTextTypeFace() {
        return this.g;
    }

    @Deprecated
    public void setTitleTextTypeFace(Typeface typeface) {
        this.g = typeface;
    }

    public int getBackgroundColor() {
        return this.h;
    }

    public void setBackgroundColor(int i) {
        this.h = i;
    }

    public int getBackgroundAlpha() {
        return this.i;
    }

    public void setBackgroundAlpha(int i) {
        this.i = i;
    }

    public int getFrameColor() {
        return this.j;
    }

    public void setFrameColor(int i) {
        this.j = i;
    }

    public int getAnchor() {
        if (this.n) {
            return 8;
        }
        return this.k;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public int a() {
        return this.k;
    }

    public void setAnchor(int i) {
        if (this.k != i || (i != 8 && this.n)) {
            if (i == 8) {
                this.n = true;
                return;
            }
            this.n = false;
            this.k = i;
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(int i) {
        this.k = i;
    }

    public int getMaxWidth() {
        return this.l;
    }

    public int getMaxWidthDp(Context context) {
        return a(this.l, context);
    }

    public void setMaxWidth(int i) {
        if (i > 0) {
            this.l = i;
        }
    }

    public void setMaxWidthDp(int i, Context context) {
        if (i > 0) {
            this.l = b(i, context);
        }
    }

    public int getMaxHeight() {
        return this.m;
    }

    public int getMaxHeightDp(Context context) {
        return a(this.m, context);
    }

    public void setMaxHeight(int i) {
        if (i > 0) {
            this.m = i;
        }
    }

    public void setMaxHeightDp(int i, Context context) {
        if (i > 0) {
            this.m = b(i, context);
        }
    }

    private int a(int i, Context context) {
        double d = i / context.getResources().getDisplayMetrics().density;
        double signum = Integer.signum((int) d);
        Double.isNaN(signum);
        Double.isNaN(d);
        return (int) (d + (signum * 0.5d));
    }

    private int b(int i, Context context) {
        double d = i * context.getResources().getDisplayMetrics().density;
        double signum = Integer.signum((int) d);
        Double.isNaN(signum);
        Double.isNaN(d);
        return (int) (d + (signum * 0.5d));
    }
}
